package chinatelecom.feilong.framework.web.license.dao;

import chinatelecom.feilong.framework.common.jpa.JpaRepository;
import chinatelecom.feilong.framework.web.license.entity.License;
import chinatelecom.feilong.framework.web.license.entity.LicenseTemplate;
import chinatelecom.feilong.framework.web.sys.entity.Dictionary;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by CJ on 2017/10/13.
 */
public interface ILicenseDao extends JpaRepository<License, Integer> {

     // 通过type_id查找是否有license相同版本的名称
     @Query(value = "select t.subject from tbl_license t where t.subject = ?",nativeQuery = true)
     String findSameLicenseName(String subject);
     // 联合查询，将用户选择的版本号选择出来
     @Query(value = "SELECT t.type FROM tbl_license t JOIN t.tbl_license_template tem WHERE tem.id = ?",nativeQuery = true)
     License findByVersion(Integer type);
     @Query(value = "SELECT * FROM tbl_license_info t  WHERE t.subject_id = ?",nativeQuery = true)
     List<License> findAllBySubjectId(Integer subjectId);
}
